package com.kmproject.haifu.app.utils;

import android.graphics.drawable.Drawable;
import android.view.View;

import com.luliang.shapeutils.DevShapeUtils;
import com.luliang.shapeutils.shape.DevShape;

import com.kmproject.haifu.R;

/**
 * Author:zhangjing
 * Time:2018/6/29  下午2:26
 * Name: this is ShapeUtils
 * Email:zhangjingworkmol@163.com
 * 工厂方法创建常用的shape形状
 */

public class ShapeFactoryUtils {
    private ShapeFactoryUtils() {
        throw new AssertionError("你不能初始化工具类");
    }

    public static void rectangleShape(View view) {
        DevShapeUtils
                .shape(DevShape.RECTANGLE)
                .solid(R.color.colorAccent)
                .radius(10)
                .into(view);
    }

    /**
     * @return 圆形的drawable
     */
    public static Drawable CircileDrawable(int color) {
        return DevShapeUtils.shape(DevShape.OVAL)
                .solid(color)
                .build();
    }

    public static Drawable rectAngleCornor4Drawable(int color) {
        return DevShapeUtils.shape(DevShape.RECTANGLE)
                .solid(color)
                .build();
    }

    /**
     * 圆角为4dp,
     *
     * @param color     背景填充色
     * @param lineColor stoke颜色
     * @return
     */
    public static Drawable rectAngleCornor4AndLineColorDrawable(int color, int lineColor) {
        return DevShapeUtils.shape(DevShape.RECTANGLE)
                .radius(5)
                .line(1, lineColor)
                .solid(color)
                .build();
    }

    /**
     * 圆角为0
     *
     * @param color
     * @param lineColor
     * @return
     */
    public static Drawable rectAngleCornor0AndLineColorDrawable(int color, int lineColor) {
        return DevShapeUtils.shape(DevShape.RECTANGLE)
                .radius(5)
                .line(1, lineColor)
                .solid(color)
                .build();
    }

    /**
     * 圆角为4dp,
     *
     * @param color     背景填充色
     * @param lineColor stoke颜色
     * @return
     */
    public static Drawable rectAngleCornor14AndLineColorDrawable(int color, int lineColor) {
        return DevShapeUtils.shape(DevShape.RECTANGLE)
                .radius(14)
                .line(1, lineColor)
                .solid(color)
                .build();
    }
}
